package cn.edu.hubu.hubusmartmedicalsystem.service.impl;

import cn.edu.hubu.hubusmartmedicalsystem.entity.Schedule;
import cn.edu.hubu.hubusmartmedicalsystem.entity.Schedule1;
import cn.edu.hubu.hubusmartmedicalsystem.mapper.Schedule1Mapper;
import cn.edu.hubu.hubusmartmedicalsystem.service.Schedule1Service;
import cn.edu.hubu.hubusmartmedicalsystem.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class Schedule1ServiceImpl implements Schedule1Service {

    @Autowired
    private Schedule1Mapper schedule1Mapper;


    @Override
    public ResultVO<List<Schedule1>> getScheduleBydeptname(String deptname) {
        List<Schedule1> schedule1s = schedule1Mapper.selectByDeptName(deptname);
        return schedule1s.isEmpty() ?
                new ResultVO<>(404, "没有找到", null) :
                new ResultVO<>(200, "查询成功", schedule1s);
    }

    @Override
    public ResultVO<List<Schedule1>> getScheduleAll() {

        List<Schedule1> schedule1s = schedule1Mapper.selectAll();
        return schedule1s.isEmpty() ?
                new ResultVO<>(404, "没有找到", null) :
                new ResultVO<>(200, "查询成功", schedule1s);


    }
    @Override
    public ResultVO<String> updateschedule(Schedule schedule){
        int result =schedule1Mapper.updateschedule(schedule);
        return result > 0 ?
                new ResultVO<>(200, "更新成功", null) :
                new ResultVO<>(500, "更新失败", null);
    }

    @Override
    public ResultVO<List<Schedule>> getschedulebyadmin() {
        List<Schedule> schedule = schedule1Mapper.selectAllbyadmin();
        return schedule.isEmpty() ?
                new ResultVO<>(404, "没有找到", null) :
                new ResultVO<>(200, "查询成功", schedule);
    }
}
